package com.person.leetcode.editor.cn;

import java.util.ArrayList;
import java.util.Arrays;

/**
  * 942.增减字符串匹配
  * 2022-05-09 17:31:55
**/
public class Sequence_0942_DiStringMatch {
    public static void main(String[] args) {
        Solution solution = new Sequence_0942_DiStringMatch().new Solution();
    }
    //leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public int[] diStringMatch(String s) {
        int max = s.length();
        int min = 0;
        int[] arr = new int[max + 1];
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if ('I' == c){
                arr[i] = min;
                min++;
            }else{
                arr[i] = max;
                max--;
            }
        }

        arr[s.length()] = max;
        return arr;
    }

}
//leetcode submit region end(Prohibit modification and deletion)

}
